﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ArgusLib.Fractals.OrbitFractals;

namespace Fraktalysator.Controls
{
	public partial class RendererEscapeTimeInputControl : UserControl, IRenderParameterInputControl
	{
		#region Private Fields
		bool requestRedraw = true;
		#endregion

		#region Constructors
		public RendererEscapeTimeInputControl()
		{
			InitializeComponent();
			this.cbColoring.Initialize(typeof(RenderParameterEscapeTime.Colorings), Localization.Enums.ResourceManager);
		}
		#endregion

		#region Properties
		public RenderParameterEscapeTime Parameter
		{
			get
			{
				RenderParameterEscapeTime parameter = new RenderParameterEscapeTime();
				parameter.Coloring = (RenderParameterEscapeTime.Colorings)this.cbColoring.SelectedEnum;
				parameter.BackgroundColor = this.cbBackground.SelectedColor;
				return parameter;
			}
			set
			{
				this.requestRedraw = false;
				this.cbColoring.Select(value.Coloring.ToUInt64());
				this.cbBackground.SelectColor(value.BackgroundColor);
				this.requestRedraw = true;
			}
		}

		ArgusLib.Fractals.IRenderParameter IRenderParameterInputControl.Parameter
		{
			get { return this.Parameter; }
			set { this.Parameter = (RenderParameterEscapeTime)value; }
		}

		public Control Control { get { return this; } }
		#endregion

		#region Eventhandling
		public event EventHandler RedrawRequested;

		private void OnRedrawRequested(object sender, EventArgs e)
		{
			if (this.requestRedraw == false)
				return;
			if (this.RedrawRequested != null)
				this.RedrawRequested(this, EventArgs.Empty);
		}
		#endregion
	}
}
